<div class="division">
<form>
<table width="100%" border="0" cellpadding="0" cellspacing="0" >
<tbody>
 
  <tr>
    <th><em class="c-red">*</em><{t}>收货人姓名：<{/t}></td>
    <td colspan=2><{input class="inputstyle" name="delivery[ship_name]" size="15" id="name" vtype="required"  type="text" value=$cons.name}></td>
  </tr>
  
  <tr>
    <th>
      <em class="c-red">*</em><{t}>手机：<{/t}>
    </td>
    <td colspan=2>
	<{if $phones}>
	 <select name="delivery[phone_setting]">
		<{foreach from=$phones item=items}>
		<option sid="<{$items.length}>" value="<{$items.area}>" <{if $cons.phone_setting == $items.area}>selected<{/if}>><{$items.country}><{$items.area}></option>
		<{/foreach}>
	 </select>
    <{/if}>
     <{input class="inputstyle" name="delivery[ship_mobile]" size="15" type="text" id="mobile" value=$cons.phone.mobile}>
    </td>
  </tr>
  <tr>
    <th>
      <{t}>固定电话：<{/t}>
    </td>
    <td colspan=2>
     <{input class="inputstyle" name="delivery[ship_tel]" size="15" type="text" id="tel" value=$cons.phone.telephone}>
     <input type="hidden" vtype="mobile_or_phone" />
    </td>
  </tr>
  <tr>
	<th>&nbsp;</th>
    <td>
		<button class="btn consignee_submit" type="submit"><span><span>保存</span></span></button>
	</td>
  </tr>
  </tbody>
</table>
</form>
</div>

<script>
//保存收货地址
$$('.consignee_submit').addEvent('click',function(e){
	e.stop();
	var _form=this.getParent('form');
	new Request({
		method:'post',
		url: '<{link app=b2c act=save_cons ctl=admin_order}>',
		data: _form.toQueryString(),
		onSuccess: function(re) {
			var rs;
			try{
				rs = JSON.parse(re);
			} catch (ex) {}
			if(rs.error)
			{
				alert(rs.error);
				return;
			}
			else
			{
				$('member_consignee').innerHTML = rs.content;
				consignee_change();
			}
		}
	}).send();
});

function consignee_change()
{
	var url_area2 = 'index.php?app=b2c&ctl=admin_order&act=getConsignee';
	var addlistRadios2=$$('input[name^=consignee[consignee_id]','receiver');
	if(addlistRadios2.length){

		addlistRadios2.addEvent('click', function(e,edit){
			this.set('checked',true);
			var _value=this.value;
			if(_value!='0'){
				if(edit){
					$('checkout-reccons').show();
				}
				else $('checkout-reccons').hide();
				$('receiver').store('b2c-cart-checkout-ship-addr', 'true');
			}else{
				$('checkout-reccons').show();
				$('receiver').store('b2c-cart-checkout-ship-addr', 'false');
			}


			new Request.HTML({
				url:url_area2,
				update:'checkout-reccons',
				onRequest:function(){
					$('checkout-reccons').set('html','<div class="font-green">loading...</div>');
				},
				onComplete:function(){

					if(_value=='0'){
						$('shipping').set('html','<div class="valierror clearfix" style=" padding-left:20px"><{t}>请先完善收货信息.<{/t}></div>');

						return;
					}


				}}).get({'consignee_id':_value,'member_id':$E('input[name^=member_id]').getValue()?$E('input[name^=member_id]').getValue():null});
		});

		if ($E('input[name^=def_person]') == null)
			addlistRadios2[0].fireEvent('click');
		else
		{
			addlistRadios2.each(function(el, index){
				if ($(el).getValue() == $E('input[name^=def_person]').getValue())
				{
					addlistRadios2[index].fireEvent('click');
				}
			});
		}
		addlistRadios2.getLast().addEvent('click',$('checkout-reccons').show.bind($('checkout-reccons')));
	}
}
$$('.addredit2','receiver').addEvent('click', function(e){
	e.stop();
	this.getPrevious('input[name^=consignee[consignee_id]').fireEvent('click',[e,true]);
});
</script>